package com.usian.admin.job;

import com.usian.admin.feign.WemediaFeign;
import com.usian.admin.service.WemediaNewsAutoScanService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Log4j2
public class WeMediaNewsAutoScanJob {

    @Autowired
    private WemediaFeign wemediaFeign;
    @Autowired
    private WemediaNewsAutoScanService wemediaNewsAutoScanService;

    /**
     * 查询数据  然后有符合规则的  进行修改状态并发布
     * @param param
     * @throws Exception
     */
    @XxlJob("wemediaAutoScanJob")
    public ReturnT<String> hello(String param) throws  Exception{
        //获取查询出状态为8的文章列表
        List<Integer> list = wemediaFeign.findRelease();
        //先判断是否为空
        if (null!=list && !list.isEmpty()){
            //进行循环集合数据
            for (Integer id : list) {
                //然后调用文章审核的方法，走到判断状态是否为8那里直接进入添加文章信息方法中，并修改状态为9，人工审核完成
                wemediaNewsAutoScanService.autoScanByMediaNewsId(id);
            }
        }else {
            return ReturnT.FAIL;
        }
    log.info("自媒体文章审核调度任务执行结束");
        return ReturnT.SUCCESS;
    }

}
